import axiosRequest from '@/utils/request';

// 管理接口

export function getUserList(keyword) {
    return axiosRequest({
        url: `/mana/user/info/list${keyword ? `?keyword=${keyword}` : ''}`,
        method: 'GET',
    });
}

export function resetUserPassword(userId) {
    return axiosRequest({
        url: `/mana/user/resetPassword?userId=${userId}`,
        method: 'POST',
    });
}

export function updateUserStatus(userId, status) {
    return axiosRequest({
        url: `/mana/user/update-status?userId=${userId}&status=${status}`,
        method: 'PUT',
    });
}

export function getArticleList(keyword) {
    return axiosRequest({
        url: `/mana/articles/list${keyword ? `?keyword=${keyword}` : ''}`,
        method: 'GET',
    });
}

export function changeArticleStatus(id, status) {
    return axiosRequest({
        url: `/mana/articles/status?articleId=${id}&status=${status}`,
        method: 'POST',
    });
}

export function deleteCarousel(fileName) {
    return axiosRequest({
        url: `/mana/carousel/delete?fileName=${fileName}`,
        method: 'DELETE',
    });
}

export function uploadCarouselForm(fileName, title) {
    return axiosRequest({
        url: `/mana/carousel/add?fileName=${fileName}&title=${title}`,
        method: 'POST',
    });
}

export function updateCarouselStatus(id, action) {
    return axiosRequest({
        url: `/mana/${id}/${action}`,
        method: 'PUT',
    });
}

//数据看板

export function getTpostsTrendData() {
    return axiosRequest({
        url: '/mana/statistics/t-posts/count',
        method: 'GET',
    });
}
export function getTpostsContentTypeData() {
    return axiosRequest({
        url: '/mana/statistics/t-posts/tags',
        method: 'GET',
    });
}

export function getTpostsGeoDistribution() {
    return axiosRequest({
        url: '/mana/statistics/t-posts/cities',
        method: 'GET',
    });
}

//  推荐页面上传文件接口
export function uploadSuggestWorksFile(type, data) {
    return axiosRequest({
        url: `/mana/commend/${type}/file/upload`,
        method: 'POST',
        data: data,
    });
}

export function deleteSuggestWorksFile(type, data) {
    return axiosRequest({
        url: `/mana/commend/${type}/file/delete`,
        method: 'DELETE',
        data: data,
    });
}

export function publishSuggestWorks(type, data) {
    return axiosRequest({
        url: `/mana/commend/${type}/publish`,
        method: 'POST',
        data: data,
    });
}

export function getSuggestWorksList(type, keyword) {
    return axiosRequest({
        url: `/mana/commend/${type}/list${keyword ? `?keyword=${keyword}` : ''}`,
        method: 'GET',
    });
}
export function updateSuggestWorksStatus(type, id, action) {
    return axiosRequest({
        url: `/mana/commend/${type}/${id}/${action}`,
        method: 'PUT',
    });
}
